﻿using Fuse8.DomainFramework.Common.Locator;

namespace Fuse8.GlobalizationFramework.Infrastructure
{
    /// <summary>
    /// Provides methods for working with globalized enetities
    /// </summary>
    public class GlobalizationMediator
    {
        /// <summary>
        /// Sets Locale property of entity to current culture
        /// </summary>
        /// <param name="entity">Entity to set locale</param>
        public static void InitCulture(ILocalizableEntity entity)
        {
            entity.Locale = DependencyServiceLocator.Current.GetInstance<IGlobalizationSetting>().CurrentCulture.Name;
        }

        /// <summary>
        /// Indicates that current culture is default
        /// </summary>
        /// <returns></returns>
        public static bool IsDefaultLanguage()
        {
            var setting = DependencyServiceLocator.Current.GetInstance<IGlobalizationSetting>();
            return setting.CurrentCulture.Name == setting.DefaultCulture.Name;
        }
    }
}